package cn.fl.inscare.service.impl;

import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.utils.BaseLogUtils;
import cn.cmm.base.framework.utils.CollectionUtils;
import cn.fl.inscare.service.IInsPayInfoService;
import cn.fl.inscare.transform.*;
import cn.fl.inscare.vo.*;
import ins.car.facade.car.car.api.IInsQueryApiService;
import ins.car.facade.car.car.condition.InsPayDetailIns03QC;
import ins.car.facade.car.car.condition.InsPayInfoQC;
import ins.car.facade.car.car.condition.InsUserPayDetailQC;
import ins.car.facade.car.car.dto.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;


/**
 * @Description: 保险支付信息表 客户端服务层接口实现
 * @Description: 业务层方法名称前缀：新增：add* 删除：remove* 修改：modify* 查询对象：select* get* 批量：batch* 查询集合：search*
 */
@Service
public class InsPayInfoServiceImpl implements IInsPayInfoService {
    private static final Logger logger = LoggerFactory.getLogger(InsPayInfoServiceImpl.class);

    @Autowired
    private IInsQueryApiService insQueryApiService;


    @Override
    public List<InsUserPayDetailVO> searchPayInfoByQc(InsPayInfoQC qc) {
        //获取报价版还款详情
        InsUserPayDetailQC userPayDetailQC = new InsUserPayDetailQC();
        userPayDetailQC.setApplicationId(qc.getApplicationId());
        userPayDetailQC.setIsDel(0);
        List<InsUserPayDetailDTO> userPayDetailDTOList = this.insQueryApiService.getUserPayDetailDtoByQc(userPayDetailQC);
        if (CollectionUtils.isEmpty(userPayDetailDTOList)) {
            BaseLogUtils.info(logger, "getCalculateInfo", String.format("获取录入版还款详情为空，applyId = %s", qc.getApplicationId()));
            return null;
        }
        return InsUserPayDetailVOTransform.toVOList(userPayDetailDTOList);
    }

    /**
     * 根据支付详情ID查询本金数据
     *
     * @param qc
     * @return
     * @throws BaseException
     */
    @Override
    public List<InsPayDetailIns03DTO> searchPay03List(InsPayDetailIns03QC qc) {
        return insQueryApiService.searchPay03List(qc);
    }
}
